var applID = getParam("applID");
var coAppl = getParam("CoAppl");
var jobNum =getParam("JobNum");
var aProps = new Array("ApplID="+applID,"CoAppl="+coAppl,"JobNum="+jobNum);
initWS("TREE","Tree.asmx?WSDL&"+aProps.join("&"));
// <<<<< Show Image/Page Frame
function showImages(){
	open("/Manager/Imaging/Imaging.aspx?ApplID="+applID,"IMAGES",features());
	// lOCALS
	function features(add){
	var s = ",status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,top=0,left=0,"+(add||'');
	var statusBar = s.match(/status=yes/i)?true:false;
		return "height="+(screen.availHeight-30-(statusBar?30:0))+",width="+(screen.availWidth-10)+s;
	}
}
function showPages(spn){
	showImage(_ImageTypeID(_treeNodeXML(spn)));
	showPage(_PageUrl(_treeNodeXML(spn)));
}
function showImage(td,alt,full){
	if( _selectImageMode() ) _selectImageMode().w.addPages(td);
	if( parseInt(td)  == 0 )return;
	var tr = getParentTR((event||{}).srcElement);
	var table = tr ? getParentTable(tr) : {};
	var prevTR = showImage.prevTR;
	showImage.prevTR = tr;
	var imageID = (td||{}).innerText ? rsField(td,"ID").value : td;
	if( !_selectImageMode() && (full || ( tr != null && prevTR === tr)) ){
		delete showPage.prevTR;
		return showIFrame(ifrmInterface,EMPTY_URL);
	}
	var src = imageID ? SHOW_APPLICANT_IMAGAE_FOLDER+"ApplID="+applID+"&folderID="+imageID : EMPTY_URL;
	showIFrame(alt?ifrmInterface:ifrmImage,src);
}
function showPage(td,alt,full){
	var pageUrl = (td||{}).innerText ? rsField(td,"PageURL").value : td;
	if( !_shiftKey() ){
		var tr = getParentTR((event||{}).srcElement);
		var table = tr ? getParentTable(tr) : {};
		var prevTR = table.selRow;
		var prevTR = showPage.prevTR;
		showPage.prevTR = tr;
		if( full || ( tr != null && prevTR === tr) ){
			delete showImage.prevTR;
			return showIFrame(ifrmImage,EMPTY_URL);
		}
	}
	showIFrame(alt?ifrmImage:ifrmInterface,pageUrl ? pageUrl+_timeParam() : EMPTY_URL);
}
function showIFrame(ifrm,src){
	//ifrm.frameElement.contentWindow.location = src+'&Time='+(new Date()).valueOf();
	src = src+(src==EMPTY_URL?"":'&Time='+(new Date()).valueOf());
	if( event && event.shiftKey )return showModelessDialog(src,null,"dialogHeight:50px;dialogWidth:50px;resizable:1;status:0");
	ifrm.location = src;
}
function _selectImageMode(v,fax){
	var ips =  top.ImagePageSelect;
	if( arguments.length > 0 ){
		if( v ){
			ips =  top.ImagePageSelect = {};
			ips.w = showModelessDialog("ImagePageSelect.htm",null,"help:no;scroll:no;status:no;dialogWidth:50px;dialogHeight:50px");
			var foo = arguments.callee.caller;
			ips.w.onclose = function(rsImages){ foo(rsImages) };
		}else{
			//if( fax )ips.func(true);
			ips.w.close();
			top.ImagePageSelect = null;
		}
	}
	return top.ImagePageSelect;
}
// >>>>> Show Image/Page Frame
// <<<<< Show Item History
function historyShow(func,title){
	var hists = typeof(historyShow.hists) == 'undefined' ? historyShow.hists = {} : historyShow.hists;
	event.cancelBubble = true;
	var histServicePath = "/include/ShowRS.htm?NoApplID=1&servicePath="+escape("/Manager/Menu/Lists.asmx?ApplID="+applID+"&hiddenFields=Hist_DateStamp&");
	try{ hists[title].close(); }catch(e){}
	hists[title] = showModelessDialog(histServicePath+"&serviceFunc="+escape(func)+"&title="+title,null,"resizable:1;status:0");
}
function showVerItemHist(el){
	historyShow("History('Verif_Item','"+_id(_treeNodeXML(el))+"')","Item History");
}
// >>>>> Show Item History
// <<<<< Faxing ***************
// >>>>> Faxing ***************
// <<<<< Image List Title
function showTitle(el,thread){
	if( !thread ){
		clearTimeout(showTitle.proc);
		return showTitle.proc = setTimeout(function(){showTitle(el,true)},300);
	}
	if( !el.over )return;
	var cs = el.currentStyle;
	var stylePopup = "border: none;color:"+cs.color+";font-Family:"+cs.fontFamily+";font-size:"+cs.fontSize+";font-weight:"+cs.fontWeight+";background-color: "+getBackgroundColor(el)+";cursor:default;padding-left: 0px;";
	var html = "<div nowrap id='divPopupHTML' style='"+stylePopup+"' "+
								"onclick=   'document.hideMe(true)' "+
								"onmouseout='document.hideMe()'>"+
								"<span id='spnPopup' oncontextmenu='return false'>"+el.innerText+"</span>"+
						"</div>"
	var	oPopup = window.createPopup();
	oPopup.document.body.innerHTML = html;
	oPopup.document.hideMe = function(ev){hidePopup(ev)};
	oPopup.show(0,0,0,0);
	if( el.offsetWidth > oPopup.document.all.spnPopup.offsetWidth )hidePopup();
	else
		oPopup.show(0,0,oPopup.document.all.spnPopup.offsetWidth+2,oPopup.document.all.spnPopup.offsetHeight+0,el);
	// Local
	function hidePopup(clickMe){
		oPopup.hide();
		if( clickMe ){
			el.click();
		}
	}
	function getBackgroundColor(el){
		for( ; el && 
					(el.currentStyle.backgroundColor == "" ||
					 el.currentStyle.backgroundColor == 'transparent'); el = el.parentElement ){}
		return el ? el.currentStyle.backgroundColor : 'transparent';
	}
}
// >>>>> Image List Title

	// ----- Node's Properties
function _PageUrl(node,value){return __getAttr(node,value)}
function _ImageTypeID(node,value){return __getAttr(node,value)}
function _MsgsNumber(node,value){return __getAttr(node,value)}
function _TabIndex(node,value){return parseInt(__getAttr(node,value))}
function _ParentID(node,value){return __getAttr(node,value)}
function _PageID(node,value){return __getAttr(node,value)}
function _expanded(node,value){ return __getAttr(node,value) }
function _type(node,value){ return __getAttr(node,value) }

function _timeParam(){return '&Time='+(new Date()).valueOf();}
function _shiftKey(){return event && event.shiftKey}
